package com.smt.core.properties;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicReference;

/**
 * Created with IntelliJ IDEA.
 * User: Jose
 * Date: 10/05/12
 * Time: 23:46
 * To change this template use File | Settings | File Templates.
 */
public class PropertiesReader
{
    private static final AtomicReference<String> PROPERTIES_FILE = new AtomicReference<String>("smt.properties");

    private static final AtomicReference<String> LOGGER_NAME = new AtomicReference<String>("loggerName");
    private static final AtomicReference<String> ASYNCHRONUS_SERVLET = new AtomicReference<String>("asynchronusServlet");

    private  static String _logger;
    private static String _asynchronusServlet;


    public static void init () throws Exception
    {
      final String PAQUETE = "com.stm.";
      InputStream is = null;
      Properties prop = new Properties ();

        try {
            is = new FileInputStream(PROPERTIES_FILE.get());
            prop.load(is);

            _asynchronusServlet = prop.getProperty(PAQUETE+ASYNCHRONUS_SERVLET);
            _logger = prop.getProperty(PAQUETE+ASYNCHRONUS_SERVLET);
        } catch (Exception e) {
            System.out.print(e.getStackTrace());  //To change body of catch statement use File | Settings | File Templates.
        }
    }


    public static Boolean get_asynchronusServlet()
    {
        return Boolean.valueOf(_asynchronusServlet);
    }

    public static String get_logger()
    {
        return _logger;
    }
}
